package com.whfc.ms.api.sys.controller;

import com.whfc.common.result.PageData;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.common.util.SessionAttr;
import com.whfc.entity.dto.Apply.rep.DailyReportDisplayRep;
import com.whfc.entity.dto.Apply.rep.WorkDailyReportDTO;
import com.whfc.entity.dto.Apply.req.AppEntryApplicationReq;
import com.whfc.entity.dto.Apply.req.AppReportRrq;
import com.whfc.entity.dto.Apply.req.WorkDailyReportQueryReq;
import com.whfc.fuum.entity.SysUser;
import com.whfc.ms.api.sys.service.SysDailyReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author xjy
 * @date 2025-09-19
 * 人员申请 and 日报
 */
@RestController
@RequestMapping("/mp/api/wxDaily")
public class SysDailyReportController {

    @Autowired
    private SysDailyReportService sysDailyReportService;

    /**
     * 人员申请方法
     * 该方法用于处理人员申请相关业务逻辑。
     *
     * @return 描述申请操作响应的字符串
     */
    @PostMapping("/wxDaily/saveReport")
    public Result saveReport(@SessionAttribute(SessionAttr.MS_USER) SysUser user, @RequestBody AppReportRrq req) {
        int i = sysDailyReportService.saveReport(user, req);
        if(i > 0){
            return ResultUtil.success("提交成功");
        }
        return ResultUtil.failure("提交失败");
    }

    /**
     * 获取日报列表支持分页
     * @return
     */
    @GetMapping("/list")
    public Result list(AppEntryApplicationReq req) {
        PageData<WorkDailyReportDTO> workDailyReportrep = sysDailyReportService.list(req);
        return ResultUtil.success(workDailyReportrep);
    }

    /**
     * 我收到的日报
     * @return
     */
    @PostMapping("/work/queryReport")
    public Result queryReport(@RequestBody WorkDailyReportQueryReq req) {
        List<DailyReportDisplayRep> displayReps = sysDailyReportService.queryReport(req);
        return ResultUtil.success(displayReps);
    }

    /**
     * 我发出的日报
     * @return
     */
    @PostMapping("/work/myDailyReport")
    public Result myDailyReport(@SessionAttribute(SessionAttr.MS_USER) SysUser sysUser, @RequestBody WorkDailyReportQueryReq req) {
        List<DailyReportDisplayRep> displayReps = sysDailyReportService.myDailyReport(sysUser,req);
        return ResultUtil.success(displayReps);
    }




















































}
